TCPDUMP_SRC=$(shell /bin/pwd -P)/tcpdump-4.5.1
LIBPCAP_SRC=$(shell /bin/pwd -P)/libpcap-1.5.3

.PHONY: all tcpdump libpcap install clean
all: tcpdump

tcpdump: libpcap
	if [ ! -f $(TCPDUMP_SRC)/Makefile ]; then \
		cd $(TCPDUMP_SRC) && ./configure --prefix=/usr --host=$(CROSSMAKE_HOST) ac_cv_linux_vers=$(KERNELVER); \
	fi
	if [ -f $(TCPDUMP_SRC)/Makefile ]; then \
		$(MAKE) -C $(TCPDUMP_SRC) ; \
	fi

libpcap: 
	if [ ! -f $(LIBPCAP_SRC)/Makefile ]; then \
		cd $(LIBPCAP_SRC) && ./configure --prefix=/usr --host=$(CROSSMAKE_HOST) ac_cv_linux_vers=$(KERNELVER) --with-pcap=linux; \
	fi
	if [ -f $(LIBPCAP_SRC)/Makefile ]; then \
		$(MAKE) -C $(LIBPCAP_SRC) ; \
	fi

install: tcpdump
	cp -f $(TCPDUMP_SRC)/tcpdump $(INSTALL_ROOT)/usr/sbin/

clean:
	if [ -f $(TCPDUMP_SRC)/Makefile ]; then \
		$(MAKE) -C $(TCPDUMP_SRC) distclean ; \
	fi
	if [ -f $(LIBPCAP_SRC)/Makefile ]; then \
		$(MAKE) -C $(LIBPCAP_SRC) distclean ; \
	fi
